<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>商品</title>
	<include file="Public:header" />
	<style type="text/css">
		.input{width:130px; border:1px solid #ccc; padding:2px;}
	</style>
	<script type="text/javascript">
		var actflg="{:C('URL_MODEL')}"=="0"?"&":"?";
		
		function select_todo(value_id,value_code,value_title,value_uom,value_price_pur,value_price_sales,value_spec,value_madein,obj_row)
		{
			if("{$objid}"=="")
			{
				$.messager.show({title:'提示',msg:'参数错误',timeout:5000,showType:'slide'});
				return false;
			}
			
            
            {$callback}
			
			if( $('#keepwindow').is(':checked') )
			{
				parent.addRow(1);
				var itemno = parseInt($('#itemno').val());
				itemno = check_parent_obj_exists(itemno);
				
				$("input[id='spitem["+itemno+"][stk_id]']",window.parent.document).attr("value",value_id);
				$("input[id='spitem["+itemno+"][stk_title]']",window.parent.document).attr("value",value_code);
				$("input[id='spitem["+itemno+"][stk_title]']",window.parent.document).attr("value",value_title);
				$("input[id='spitem["+itemno+"][stk_uom]']",window.parent.document).attr("value",value_uom);
				if("{$objpurprice}"!=""){ $("input[id='spitem["+itemno+"][price]']",window.parent.document).attr("value",value_price_pur); }
				if("{$objsalesprice}"!=""){ $("input[id='spitem["+itemno+"][price]']",window.parent.document).attr("value",value_price_sales); }
				
				$("input[id='spitem["+itemno+"][spec]']",window.parent.document).attr("value",value_spec);
				$("input[id='spitem["+itemno+"][madein]']",window.parent.document).attr("value",value_madein);
				itemno++;
				$('#itemno').attr("value",itemno);
				//$('.pages a').attr( 'href' , $('.pages a').attr('href').replace(/itemno=(\d+)/i, "itemno=" + itemno) ); 
				$(".pages a").each(function(){
					$(this).attr( 'href' , $(this).attr('href').replace(/itemno=(\d+)/i, "itemno=" + itemno) );
				});
				
				$('.'+obj_row).css({"background":"#eeeeee"});
			}
			else
			{
				if("{$objid}"!=""){ $("input[id='{$objid}']",window.parent.document).attr("value",value_id); }
				if("{$objcode}"!=""){ $("input[id='{$objcode}']",window.parent.document).attr("value",value_code); }
				if("{$objtitle}"!=""){ $("input[id='{$objtitle}']",window.parent.document).attr("value",value_title); }
				if("{$objuom}"!=""){ $("input[id='{$objuom}']",window.parent.document).attr("value",value_uom); }
				if("{$objpurprice}"!=""){ $("input[id='{$objpurprice}']",window.parent.document).attr("value",value_price_pur); }
				if("{$objsalesprice}"!=""){ $("input[id='{$objsalesprice}']",window.parent.document).attr("value",value_price_sales); }
				
				if("{$objspec}"!=""){ $("input[id='{$objspec}']",window.parent.document).attr("value",value_spec); }
				if("{$objmadein}"!=""){ $("input[id='{$objmadein}']",window.parent.document).attr("value",value_madein); }
				
				parent.close_popup_window();
			}
		}
		
		function check_parent_obj_exists(itemno)
		{
			if( $("input[id='spitem["+itemno+"][stk_id]']",window.parent.document).length>0 )
			{
				return parseInt(itemno);
			}
			else
			{
				return check_parent_obj_exists( parseInt(itemno) + 1 );
			}
		}
		
		function EnterPress(e)
		{
			var e = e || window.event; 
			if(e.keyCode == 13){ 
				$('#btn-search-todo').click();
			} 
		}

	</script>
</head>
<body class="">
	<div class="demo-info space-out-5px">
		<div class="demo-tip icon-tip"></div>
		<div>点击需要选择的商品</div>
		<div>
		<form id="frm_search" method="post" action="{:U('Stk/stkmas_popup')}" style="margin:10px auto 0px 25px;">
		<div style="float:left; margin:0px; padding:2px;">
		<select id="cid" name="cid" class="easyui-combobox" editable="false" style="width:190px;">
								<option value='0'>顶级类别</option>
								<volist name='classlist' id="classlist">
								<option value='{$classlist["id"]}'><for start="2" end="$classlist['count']">|----</for>{$classlist['classname']}</option>
								</volist>
		</select>
		</div>
		<script type="text/javascript">$("#cid").attr("value","{$cid}");</script>
		<input type="hidden" id="objid" name="objid" class="" value="{$objid}" />
		<input type="hidden" id="objcode" name="objcode" class="" value="{$objcode}" />
		<input type="hidden" id="objtitle" name="objtitle" class="" value="{$objtitle}" />
		<input type="hidden" id="objuom" name="objuom" class="" value="{$objuom}" />
		<input type="hidden" id="objpurprice" name="objpurprice" class="" value="{$objpurprice}" />
		<input type="hidden" id="objsalesprice" name="objsalesprice" class="" value="{$objsalesprice}" />
        <input type="hidden" id="objdetail" name="objdetail" class="" value="{$objdetail}" />
        <input type="hidden" id="objspec" name="objspec" class="" value="{$objspec}" />
        <input type="hidden" id="objmadein" name="objmadein" class="" value="{$objmadein}" />
        <input type="hidden" id="callback" name="callback" class="" value="{$callback}" />
		<input type="hidden" id="itemno" name="itemno" value="{$itemno}" />
		
		<input type="text" id="keywords" name="keywords" class="input" value="{$keywords}" onkeypress="EnterPress(event)" onkeydown="EnterPress()" />		
		<a href="javascript:;" id="btn-search-todo" class="easyui-linkbutton" iconCls="icon-search" onclick="$('#frm_search').submit();">搜索</a>
		<input type="checkbox" id="keepwindow" name="keepwindow" value="1" onchange="$('#frm_search').submit();" <if condition="($keepwindow eq '1')">checked</if>  /><label for="keepwindow">保持窗口打开</label>
		</form>
		</div>
	</div>
	<div class=" space-out-10px">
	
	<div class="list-title">
		<div class="list-t-l w100px">编码</div>
		<div class="list-t-l w50px">商品</div>
        <if condition="($objdetail eq '1' OR $objdetail eq 'true' OR $objdetail eq 'Y')">
        <!--div class="list-t-l w60px">数量</div>
        <div class="list-t-l w60px">批号</div>
        <div class="list-t-l w80px">有效期</div>
        <div class="list-t-l w80px">批准文号</div-->
        <div class="list-t-l w150px"></div>
        <else/>
        <div class="list-t-l w150px"></div>
        </if>
        <div class="list-t-l w100px">规格</div>
        <div class="list-t-l w60px">产地</div>
        
		<div class="list-t-r w50px">状态</div>
	</div>
	
	<div class="list-box">
	<volist name="datalist" id="datalist">
	<div class="list-body list-body-{$key}" <if condition="($objdetail eq '1' OR $objdetail eq 'true' OR $objdetail eq 'Y')">style="border-bottom: #8F5700 solid 1px;"</if> onclick="javascript:select_todo('{$datalist.id}','{$datalist.stk_c}','{$datalist.title}','{$datalist.uom}','{$datalist.price_pur|get_round=###,6,true}','{$datalist.price_sales|get_round=###,6,true}','{$datalist.spec}','{$datalist.madein}','list-body-{$key}');" style="cursor:pointer;">
		<div class="list-t-l w100px">{$datalist.stk_c}</div>
		<div class="list-t-l w200px" alt="{$datalist.title}" title="{$datalist.title}">{$datalist.title}</div>
        <div class="list-t-l w100px" alt="{$datalist.spec}" title="{$datalist.spec}">{$datalist.spec}</div>
        <div class="list-t-l w150px" alt="{$datalist.madein}" title="{$datalist.madein}">{$datalist.madein}</div>
		<div class="list-t-r w50px"><img src="__PUBLIC__/Images/{$datalist.status_flg}.png" alt="{$datalist.status_flg}" title="{$datalist.status_flg}" /></div>       
        
	</div>
    <php>
        if($datalist['stk_detail']){
        foreach($datalist['stk_detail'] as $row){
    </php>
    <div class="list-body" style="color:#666666;">
		<div class="list-t-l w50px">&nbsp;</div>
		<div class="list-t-l w100px"><span class="tree-hit tree-expanded tree-expanded-hover"></span><php>echo $row['wh_title'];</php></div>
        <div class="list-t-l w60px"><php>echo get_round($row['open_qty'],2);</php></div>
        <div class="list-t-l w60px"><php>echo $row['batch_no'];</php></div>
        <div class="list-t-l w80px"><php>echo get_date('Y-m-d',$row['expiry_date']);</php></div>
        <div class="list-t-l w80px"><php>echo $row['approval_no'];</php></div>
        <!--div class="list-t-l w60px"><php>echo $row['spec'];</php></div>
        <div class="list-t-l w60px"><php>echo $row['madein'];</php></div-->        
	</div>
    <php>}}</php>
	</volist>
	</div>	
	
	</div>
	
	<div class="demo-info space-out-5px">
		<div class="demo-tip icon-tip"></div>
		<div class="pages">&nbsp;{$page}</div>
	</div>
</body>
</html>
